package integration

import (
	"context"
	pb "gitee.com/micro-services/protocol/tag/api"
	mpb "gitee.com/micro-services/protocol/tag/server"
)

func CreateHotelTag(ctx context.Context, r *pb.APICreateHotelTagReq) (*pb.APICreateHotelTagRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.CreateHotelTag(ctx, &mpb.CreateHotelTagReq{
		HotelID: r.HotelID,
		Tag:     r.Tag,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APICreateHotelTagRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}

func DeleteHotelTag(ctx context.Context, r *pb.APIDeleteHotelTagReq) (*pb.APIDeleteHotelTagRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.DeleteHotelTag(ctx, &mpb.DeleteHotelTagReq{
		HotelID: r.HotelID,
		TagID:   r.TagID,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIDeleteHotelTagRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}

func HotelTags(ctx context.Context, r *pb.APIHotelTagsReq) (*pb.APIHotelTagsRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.HotelTags(ctx, &mpb.HotelTagsReq{
		HotelID: r.HotelID,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIHotelTagsRsp{
		Tag: rsp.Tag,
	}, nil
}

func CreateRoomTag(ctx context.Context, r *pb.APICreateRoomTagReq) (*pb.APICreateRoomTagRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.CreateRoomTag(ctx, &mpb.CreateRoomTagReq{
		RoomID: r.RoomID,
		Tag:    r.Tag,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APICreateRoomTagRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}

func DeleteRoomTag(ctx context.Context, r *pb.APIDeleteRoomTagReq) (*pb.APIDeleteRoomTagRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.DeleteRoomTag(ctx, &mpb.DeleteRoomTagReq{
		RoomID: r.RoomID,
		TagID:  r.TagID,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIDeleteRoomTagRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}

func RoomTags(ctx context.Context, r *pb.APIRoomTagsReq) (*pb.APIRoomTagsRsp, error) {
	rsp, err := GetProxyManger().TagClientProxy.RoomTags(ctx, &mpb.RoomTagsReq{
		RoomID: r.RoomID,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIRoomTagsRsp{
		Tag: rsp.Tag,
	}, nil
}
